<?php namespace Framework\Kernel;

class App
{
	public function run()
	{
		header("Content-type:text/html;charset=utf-8");
		
		spl_autoload_register([$this,'autoload']);
		//加载函数库
		require 'framework/Kernel/functions.php';

		$m = isset($_GET['m'])?$_GET['m']:'Home';
		$c = isset($_GET['c'])?$_GET['c']:'Index';
		$a = isset($_GET['a'])?$_GET['a']:'index';

		define('MODULE',$m);//模型常量
		define('CONTROLLER',$c);//控制器
		define('ACTION',$a);//执行动作
		// $url ="?m=".MODULE."&c=".CONTROLLER."&a={$info[0]}"; 1
		//加载框架配置
		C(require 'framework/config.php');
		//加载公共配置
		C(require 'app/Common/Conf/config.php');
		//加载模块配置
		C(require 'app/'.$m.'/Conf/config.php');

		$class= $m.'\\Controller\\'.$c.'Controller';
		$obj = new $class;
		$obj->$a();
	}

	//类自动加载
	public function autoload($class)
	{
		$class = str_replace('\\', '/', $class);
		if(substr($class,0,9)=='Framework')
		{
			//加载框架内的类
			$file = $class.'.php';
		}
		else
		{	//加载项目类
			$file ='app/'.$class.'.php';
		}
		// p($file);
		require_once($file);

	}
}





